🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

web3-provider-engine

Package Overview
Dependencies
Maintainers
5
Versions
192
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

web3-provider-engine

A JavaScript library for composing Ethereum provider objects using middleware modules

15.0.12
Source
npm
Version published
Weekly downloads
149K
-13.85%
Maintainers
5
Weekly downloads
 
Created

What is web3-provider-engine?

The web3-provider-engine is a JavaScript library that allows developers to create custom Ethereum providers. It is designed to be a modular and extensible provider engine that can be used to manage multiple Ethereum networks and handle various types of requests. It is particularly useful for managing custom signing logic, caching, and other middleware functionalities.

What are web3-provider-engine's main functionalities?

Custom Middleware

This feature allows you to add custom middleware to the provider engine. In this example, we add an RPC subprovider to connect to the Ethereum mainnet via Infura. The engine can be extended with additional middleware to handle custom logic.

const Web3ProviderEngine = require('web3-provider-engine');
const RpcSubprovider = require('web3-provider-engine/subproviders/rpc');
const engine = new Web3ProviderEngine();
engine.addProvider(new RpcSubprovider({ rpcUrl: 'https://mainnet.infura.io' }));
engine.start();

Caching

The caching feature allows you to cache certain types of requests to improve performance. By adding a CacheSubprovider, you can cache responses for specific requests, reducing the number of network calls.

const CacheSubprovider = require('web3-provider-engine/subproviders/cache');
engine.addProvider(new CacheSubprovider());

Custom Signing

This feature allows you to implement custom signing logic. The HookedWalletSubprovider can be used to define how accounts are retrieved and how transactions are signed, enabling custom wallet implementations.

const HookedWalletSubprovider = require('web3-provider-engine/subproviders/hooked-wallet');
engine.addProvider(new HookedWalletSubprovider({
  getAccounts: (cb) => cb(null, ['0x1234...']),
  signTransaction: (txParams, cb) => cb(null, '0x5678...')
}));

Other packages similar to web3-provider-engine

FAQs

Package last updated on 28 May 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts